package com.spring.sunflower.common

import com.spring.sunflower.base.BaseObserver
import com.spring.sunflower.base.BasePresenter
import com.spring.sunflower.bean.*

/**
 * Created by Kevin on 2021/8/30<br/>
 *
 * Describe:<br/>
 */
class WithDrawPresenter(baseView: CommonContract.WithDrawView) :
    BasePresenter<CommonContract.WithDrawView>(baseView) {
    fun getAccountMoneyInfo(userID: String) {
        val observable = requestDataSource.getAccountMoneyInfo(userID)
        addDisposable(observable, object : BaseObserver<AccountMoneyBean>(baseView) {
            override fun onSuccess(bean: AccountMoneyBean) {
                baseView.showAccountMoneyInfo(bean.datas!!)
            }

            override fun onError(status: Int, msg: String?) {
            }
        })
    }

    fun requestAuthCode(phoneNum: String?, type: String?) {
        val observable = requestDataSource.requestAuthCode(phoneNum, type)
        addDisposable(observable, object : BaseObserver<AuthCodeBean?>(baseView) {
            override fun onSuccess(bean: AuthCodeBean?) {
//                baseView.requestFinish()
            }

            override fun onError(status: Int, msg: String) {
//                baseView.showError(status, msg)
            }
        })
    }

    fun applyWithdraw(map: Map<String, String>) {
        val observable = requestDataSource.getApplyWithdraw(map)
        addDisposable(observable, object : BaseObserver<BlackHasBean?>(baseView) {
            override fun onSuccess(bean: BlackHasBean?) {
                baseView.requestFinish()
            }

            override fun onError(status: Int, msg: String) {
//                baseView.showError(status, msg)
            }
        })
    }
    fun bindPhone(phoneNum: String,code:String) {
        val observable = requestDataSource.bindPhone(phoneNum,code)
        addDisposable(observable, object : BaseObserver<BlackHasBean>(baseView) {
            override fun onSuccess(bean: BlackHasBean) {
                baseView.bindSuccess()
            }

            override fun onError(status: Int, msg: String?) {
            }
        })
    }
}